﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace IMCOM.Imagiality.ImageProcessing.Canvas2D.AutoContrast
{
    public abstract class AutoContrastLineScaling : AutoContrastLineDrawn
    {
        protected AutoContrastHandle activeHandle;
        Point previousMousePosition;

        public AutoContrastLineScaling(AutoContrastImageEventListener controller, AutoContrastHandle activeHandle) : base(controller)
        {
            this.activeHandle = activeHandle;
        }

        public override void MouseDown(object sender, MouseEventArgs e)
        {
        }

        public override void MouseMoved(object sender, MouseEventArgs e)
        {
            if (!previousMousePosition.IsEmpty)
            {
                Point mouseDelta = new Point(e.X - previousMousePosition.X, e.Y - previousMousePosition.Y);
                MovePoint(mouseDelta);
                controller.RefreshCanvas();
            }

            // set previous mouse position
            previousMousePosition = new Point(e.X, e.Y);
        }

        protected abstract void MovePoint(Point mouseDelta);

        public override void MouseUp(object sender, MouseEventArgs e)
        {
            SetControllerState(new AutoContrastLineDrawn(controller));
        }
    }
}
